package com.czk.springboot.controller.mqtt;

import com.czk.springboot.config.mqtt.MqttGateway;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenzhangkun
 * @ClassName MqttController
 * @description: mqtt测试控制器
 * @date 2025年09月01日
 */
@RestController
@RequestMapping(value = "/mqtt")
public class MqttController {
    @Resource
    private MqttGateway mqttGateway;

    @PostMapping("/sendToDefaultTopic")
    public String sendToDefaultTopic(String payload) {
        mqttGateway.sendToMqtt(payload);
        return "success";
    }

    @PostMapping("/sendToTopic")
    public String sendToTopic(String payload, String topic) {
        mqttGateway.sendToMqtt(payload, topic);
        return "success";
    }

}
